<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
<head>
    <title></title>
    <meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
    <script type="text/javascript">
        <!--
        function format(shijianchuo)
        {
//shijianchuo是整数，否则要parseInt转换
            var time = new Date(shijianchuo);
            var y = time.getFullYear();
            var m = time.getMonth()+1;
            var d = time.getDate();
            var h = time.getHours();
            var mm = time.getMinutes();
            var s = time.getSeconds();
            return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
        }
        var ligerTable = null;
        $(function(){
            $('.select-chosen').chosen();
            ligerTable = $('#table').ligerGrid({
                width:'98%',
                enabledSort:false,
                pageSizeOptions:[5,10,20,50,100,200],
                height:'auto',
                alternatingRow:true,
                url:'${base}/${route}/driver/getList',
                delayLoad:false,
                columns:[
                    {display:'公司标识',name:'companyId',id:'companyId',align:'center',minWidth:80},
                    {display:'机动车驾驶证编号',name:'licenseId',id:'licenseId',align:'center',minWidth:80},
                    {display:'行政区划代码',name:'driverRegionCode',id:'driverRegionCode',align:'center',minWidth:80},
                    {display:'车牌号码',name:'vehicleNo',id:'vehicleNo',align:'center',minWidth:80},
                    {display:'定位时间',name:'positionTime',id:'positionTime',align:'center',minWidth:80},
                    {display:'经度',name:'longitude',id:'longitude',align:'center',minWidth:80},
                    {display:'纬度',name:'latitude',id:'latitude',align:'center',minWidth:80},
                    {
                        display:'坐标加密标识',
                        name:'encrypt',
                        id:'encrypt',
                        align:'center',
                        minWidth:80,
                        render:function(row){
                            if(row.encrypt == 1){
                                return 'GCJ-02测绘局标准';
                            } else if(row.encrypt == 2){
                                return 'WGS84 GPS标准';
                            } else if(row.encrypt == 3){
                                return 'BD-09百度标准';
                            }
                            return '';
                        }
                    },
                    {display:'方向角',name:'direction',id:'direction',align:'center',minWidth:80},
                    {display:'海拔高度',name:'elevation',id:'elevation',align:'center',minWidth:80},
                    {display:'瞬时速度',name:'speed',id:'speed',align:'center',minWidth:80},
                    {
                        display:'营运状态',
                        name:'bizStatus',
                        id:'bizStatus',
                        align:'center',
                        minWidth:80,
                        render:function(row){
                            if(row.bizStatus == 1){
                                return '载客';
                            } else if(row.bizStatus == 2){
                                return '接单';
                            } else if(row.bizStatus == 3){
                                return '空驶';
                            } else if(row.bizStatus == 4){
                                return '停运';
                            }
                            return '';
                        }
                    },
                    {display:'订单编号',name:'orderId',id:'orderId',align:'center',minWidth:80}
                ],
                onDblClickRow: function (data, rowindex, rowobj){
                    layer.open({
                        title:'${module}',
                        type:2,
                        maxmin:false,
                        area: ['100%', '100%'],
                        content:'${base}/${route}/driver/view/'+data.id
                    });
                }
            });

            function reload(){
                if(ligerTable){
                    var startTime = $('#txtStartTime').val();
                    var endTime = $('#txtEndTime').val();
                    var searchKey = $('#txtSearchKey').val();
                    ligerTable.setParm('startTime',startTime);
                    ligerTable.setParm('endTime',endTime);
                    ligerTable.setParm('searchKey',searchKey);
                    ligerTable.reload();
                }
            }
            $('#btnSearch').click(function(){
                reload();
            });
            $('.date-picker').datepicker({autoclose:true});
            $('#btnLoc').click(function(){
                if(ligerTable){
                    var row = ligerTable.getSelectedRow();
                    if(!row || row.helpId < 1){
                        layer.msg('请选择行')
                        return;
                    }
                    var id = row.id;
                    var url='${base}/${route}/driver/loc/'+id;
                    changePage(url);
                }
            });
            $('#btnEdit').click(function(){
                if(ligerTable){
                    var row = ligerTable.getSelectedRow();
                    if(!row || row.helpId < 1){
                        layer.msg('请选择行')
                        return;
                    }
                    var id = row.id;
                    var url='${base}/${route}/driver/edit/'+id;
                    changePage(url);
                }
            });
            $('#btnRemove').click(function(){
                if(ligerTable){
                    var row = ligerTable.getSelectedRow();
                    if(!row || row.helpId < 1){
                        layer.msg('请选择行')
                        return;
                    }
                    var id = row.id;
                    layer.confirm('确定要删除吗？',function(){
                        $.ajax({
                            url:'${base}/${route}/driver/remove/'+id,
                            type:'POST',
                            data:{},
                            dataType:'json',
                            success:function(rst){
                                layer.alert(rst.message);
                                if(rst.status=='OK' && ligerTable != null ){
                                    ligerTable.reload();
                                }
                            }
                        });
                    });
                }
            });
        });
        //-->
    </script>
</head>
<body class="$configs["skinName"]">
		<#include "common/breadcrumb.ftl">
<div class="widget-box">
    <div class="widget-header widget-header-flat">
        <h5 class="lighter">
            <i class="fa fa-search"></i>
        ${module}查询
        </h5>
    </div>
    <div class="widget-body">
        <div class="widget-main">
            <div class="row">
                <div class="col-sm-1">
                    <label>开始时间</label>
                </div>
                <div class="col-sm-3">
                    <div class="input-group">
                        <input class="form-control date-picker" id="txtStartTime" type="text" value="${startTime}" data-date-format="yyyy-mm-dd" />
                        <span class="input-group-addon">
									<i class="fa fa-calendar"></i>
								</span>
                    </div>
                </div>
                <div class="col-sm-1">
                    <label>截至时间</label>
                </div>
                <div class="col-sm-3">
                    <div class="input-group">
                        <input class="form-control date-picker" id="txtEndTime" type="text" value="${endTime}" data-date-format="yyyy-mm-dd" />
                        <span class="input-group-addon">
									<i class="fa fa-calendar"></i>
								</span>
                    </div>
                </div>
            </div>
            <div class="space-4"></div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="input-group">
                        <span class="input-group-addon">关键字</span>
                        <input id="txtSearchKey" type="text" class="form-control search-query" placeholder="请输关键字" />
                        <span class="input-group-btn">
									<button id="btnSearch" type="button" class="btn btn-purple btn-sm">
										查询
										<i class="icon-search icon-on-right bigger-110"></i>
									</button>
								</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="widget-box">
    <div class="widget-header">
        <h5 class="lighter">
            <i class="icon-table"></i>
        ${module}列表
        </h5>
        <!--非查询者有该操作-->
				<#if user?exists && viewerRole?exists && user.roleId != viewerRole>
				<div class="widget-toolbar">
                    <button id="btnLoc" type="button" class="btn btn-primary btn-xs">
                        <i class="fa fa-check-square-o"></i>位置
                    </button>

                    <button id="btnRemove" type="button" class="btn btn-primary btn-xs">
                        <i class="fa fa-trash-o"></i>删除
                    </button>
                </div>
                </#if>
    </div>
    <div class="widget-body">
        <div id="table"><div>
        </div>
        </div>
        </body>
</html>